<%@ page contentType="text/html;charset=utf-8"%>
<%@ page
	import="java.io.*, java.sql.*, java.util.*, java.text.*, napal.*, util.*, napal.*"%>
<%@ page import="org.apache.ibatis.*"%>
<%@ page import="java.util.Date"%>

<%
	request.setCharacterEncoding("utf-8");
%>
<%@ include file="./Header.jsp"%>
			</td>
		</TR>
		<TR HEIGHT="100">
		<td>
<a href="giguan.jsp" class="btn btn-link btn-small">기자재관리<br></a>
>  기자재수정<br><br><br>
<form method="post">
<% 


EquipmentDetail r = new EquipmentDetail();
if(request.getParameter("str_aid")!=null){
	String str_aid = request.getParameter("str_aid");
	session.setAttribute("sur",request.getParameter("str_aid"));
	int aaid = Integer.parseInt(str_aid); 
	r = RentalHome.Detail(aaid);

}


%>
<%String selectedCategory = request.getParameter("select01");
	String selectedCategory1 = request.getParameter("select02");
	int mo1=0;
	 %>
	<%	int de1=0;
	if ("소프트웨어공학과".equals(selectedCategory))
		de1 = 1;
	else if ("정보통신공학과".equals(selectedCategory))
		de1 = 2;
	else if ("멀티미디어시스템공학과".equals(selectedCategory))
		de1 = 3;
	else if ("글로컬IT학과".equals(selectedCategory))
		de1 = 4;
	else if ("디지털컨텐츠학과".equals(selectedCategory))
		de1 = 5;
	else if ("신문방송학과".equals(selectedCategory))
		de1 = 6;
	else if ("경영학부".equals(selectedCategory))
		de1 = 7;
	else if ("사회과학부".equals(selectedCategory))
		de1 = 8;
	else if ("일어일본학과".equals(selectedCategory))
		de1 = 9;
	else if ("영어학과".equals(selectedCategory))
		de1 = 10;
	else if ("신학과".equals(selectedCategory))
		de1 = 11;
	else if ("사회복지학과".equals(selectedCategory))
		de1 = 12;
	else if ("중어중국학과".equals(selectedCategory))
		de1 = 13;



String num = request.getParameter("num");

String de = request.getParameter("de");
String st = request.getParameter("st");
String date1 = request.getParameter("date");
String money = request.getParameter("money");

String sang = request.getParameter("sang");
String yn = request.getParameter("yn");
String bigo = request.getParameter("bigo");
String errMsg="";

%>
<table class="table table-bordered">
     <% 

     String nm=session.getAttribute("sur").toString();
       int nnm=Integer.parseInt(nm);
       int m=0;
       if ("수정".equals(request.getParameter("cmd5"))) { 
           int mooo=Integer.parseInt(money);
           
           if(selectedCategory1.equals("선택안함")){
         		errMsg="모델을 선택하세요";
         		%>
         			<font color="red"> <%=errMsg%>
         			</font>
         		<%}
           
     		else  if(selectedCategory.equals("학과선택")){
     			errMsg="학과를 선택하세요";
     		%>
     				<font color="red"> <%=errMsg%>
     				</font>
     			<%}
     		
     		else if(st==""){
     		errMsg="보관사용처를 입력하세요";
     		%>
     			<font color="red"> <%=errMsg%>
     			</font>
     		<%}
     		
     		else if(date1==""){
     			errMsg="구매날짜를 입력하세요";
     		%>
     		<font color="red"> <%=errMsg%>
     			</font>
     		    <%}
       	  
     		else if(date1.length()!=10){
     			errMsg="구매날짜를 형식을 정확히 입력하세요";
     		%>
     		<font color="red"> <%=errMsg%>
     			</font>
     		    <%}
     		
     		else if(money==""){
     			errMsg="구매금액을 입력하세요";
     		%>
     		<font color="red"> <%=errMsg%>
     			</font>
     		    <%}
     		
     		else if(sang==""){
     			errMsg="기가재상태를 입력하세요";
     		%>
     		<font color="red"> <%=errMsg%>
     			</font>
     		    <%}
     		
     		else if(yn==""){
     			errMsg="	공개여부를 입력하세요";
     		%>
     		<font color="red"> <%=errMsg%>
     			</font>
     		    <%}
     		    
     		  else if(bigo==""){
     			  errMsg="비고를 입력하세요";
     		  %>
     		<font color="red"> <%=errMsg%>
     			</font>
     		    <%}
     		  else{

     	        	   Model e=RentalHome.modelenroll(selectedCategory1);
     	               m=e.get모델번호();
     	
           RentalHome.updateEq(num, de1, m, st, sang, date1, mooo, yn,bigo,nnm);
           %><script language=javascript>
         self.window.alert("기자재를 수정하였습니다.");
         location.href="EquipmentDetail_m.jsp?str_aid=<%=nnm%>";
      </script> 
         <% }
         }%>

			
	
		<tr>
			<td>모델명</td>
			<Td><select name="select02">
									<OPTION value="선택안함">모델선택</OPTION>

									<%
										for (Model g : RentalHome.model()) {
									%>
									<OPTION VALUE="<%=g.get모델명()%>"
										<%=g.get모델명().equals(selectedCategory1) ? "selected"
						: ""%>><%=g.get모델명()%></OPTION>

									<%
										}
									%>
					</SELECT></td>
							</tr>
		<tr>
			<td>기자재관리번호</td>
			<Td><input type="text" name="num"  value="<%=r.get기자재관리번호()%>"></td>
		</tr>
		<tr>
			<td>학과이름</td>
			<Td><select name="select01">
									<OPTION VALUE='학과선택'>학과선택</OPTION>
									<OPTION VALUE="소프트웨어공학과""소프트웨어공학과".equals(selectedCategory) ? "selected" : "" >소프트웨어공학과</OPTION>
									<OPTION VALUE="정보통신공학과""정보통신공학과".equals(selectedCategory) ? "selected" : "" >정보통신공학과</OPTION>
									<OPTION VALUE="멀티미디어시스템공학과""멀티미디어시스템공학과".equals(selectedCategory) ? "selected" : "" >멀티미디어시스템공학과</OPTION>
									<OPTION VALUE="글로컬IT학과""글로컬IT학과".equals(selectedCategory) ? "selected" : "" >글로컬IT학과</OPTION>
									<OPTION VALUE="디지털컨텐츠학과""디지털컨텐츠학과".equals(selectedCategory) ? "selected" : "" >디지털컨텐츠학과</OPTION>
									<OPTION VALUE="신문방송학과""신문방송학과".equals(selectedCategory) ? "selected" : "" >신문방송학과</OPTION>
									<OPTION VALUE="경영학부""경영학부".equals(selectedCategory) ? "selected" : "" >경영학부</OPTION>
									<OPTION VALUE="사회과학부""사회과학부".equals(selectedCategory) ? "selected" : "" >사회과학부</OPTION>
									<OPTION VALUE="일어일본학과""일어일본학과".equals(selectedCategory) ? "selected" : "" >일어일본학과</OPTION>
									<OPTION VALUE="영어학과""영어학과".equals(selectedCategory) ? "selected" : "" >영어학과</OPTION>
									<OPTION VALUE="신학과""신학과".equals(selectedCategory) ? "selected" : "" >신학과</OPTION>
									<OPTION VALUE="사회복지학과""사회복지학과".equals(selectedCategory) ? "selected" : "" >사회복지학과</OPTION>
									<OPTION VALUE="중어중국학과""중어중국학과".equals(selectedCategory) ? "selected" : "" >중어중국학과</OPTION></td>
		</tr>
		<tr>
			<td>보관사용처</td>
			<td><input type="text" name="st"  value="<%=r.get보관사용처()%>"></td>
		</tr>
		<tr>
			<td>구매날짜</td>
			<td><input type="text"  name="date" value="<%=r.get구매날짜()%>"></td>
		</tr>
		<tr>
			<td>구매금액</td>
			<td><input type="text"  name="money" value="<%=r.get구매금액()%>"></td>
		</tr>
		<tr>
			<td>기자재상태</td>
			<Td><input type="text" name="sang"  value="<%=r.get기자재상태()%>"></td>
		</tr>
		<tr>
			<td>공개여부</td>
			<td><input type="text" name="yn"  value="<%=r.get공개여부()%>"></td>
		</tr>
		<tr>
			<td>비고</td>
			<td><input type="text"  name="bigo" value="<%=r.get비고()%>"></td>
		</tr>
	</table>
	<INPUT name="cmd5" class="btn btn-inverse" TYPE="submit" VALUE="수정">

	</form>		
	</TD>
</TR>

<TR HEIGHT="100">
<TD><%@ include file="./bottom.jsp"%></TD> 
</TR>
</TABLE>
</body>
</html>